package com.linkage.educloud.ah.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mr'Tang on 2018/11/6.
 */

public class LabelBean {
    private String id;
    private String name;
    private String is_show;

    public static List<LabelBean> parseFromJson(JSONArray jsonArray) {
        List<LabelBean> list = new ArrayList<>();
        LabelBean add_all = new LabelBean();
        add_all.setId("0");
        add_all.setIs_show("1");
        add_all.setName("全部");
        list.add(add_all);
        for (int a = 0; a < jsonArray.length(); a++) {
            LabelBean label = new LabelBean();
            JSONObject jsonObj = null;
            try {
                jsonObj = jsonArray.getJSONObject(a);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            label.setId(jsonObj.optString("id"));
            label.setName(jsonObj.optString("name"));
            label.setIs_show("1");
            list.add(label);
        }
        return list;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIs_show() {
        return is_show;
    }

    public void setIs_show(String is_show) {
        this.is_show = is_show;
    }
}
